<script>

/**
 * Orders Component
 */
import Multiselect from "vue-multiselect";
export default {
  components: {
    Multiselect,
  },
  data() {
    return {
      ordersData: [
        {
          title: "市住房和城乡建设局局长谢进才开展春节前燃气与供热安全生产督导检查",
          source: "徐州市住房和城乡建设局",
          emotion: "积极",
          industry: "房产行业",
          cause: "乡村振兴",
          article: "社会",
          time: "12分钟前"
        },{
          title: "华裔教授陈刚首次就＂间谍＂指控案受访：很生气，很害怕",
          source: "环球网",
          emotion: "消极",
          industry: "教育行业",
          cause: "职务调整",
          article: "教育",
          time: "17分钟前"
        },{
          title: "向海而生 生机勃勃 海南商报掌政通传媒集团挂牌成立",
          source: "椰网",
          emotion: "积极",
          industry: "文化传媒",
          cause: "机构成立",
          article: "财经",
          time: "21分钟前"
        },{
          title: "比克斯塔夫：莫布利对比赛有很深理解，关键篮板说明了这点",
          source: "虎扑篮球",
          emotion: "中性",
          industry: "体育产业",
          cause: "竞技比赛",
          article: "体育",
          time: "21分钟前"
        },{
          title: "开讲座、学中医、剪窗花，湖南省妇幼举办医患互动会",
          source: "潇湘晨报",
          emotion: "中性",
          industry: "医疗行业",
          cause: "行业交流",
          article: "健康",
          time: "22分钟前"
        },{
          title: "市住建局全面学习贯彻全国住房和城乡建设工作会议精神",
          source: "宿州市住房和城乡建设局",
          emotion: "积极",
          industry: "房产行业",
          cause: "乡村振兴",
          article: "时事",
          time: "25分钟前"
        },{
          title: "习近平主持中共中央政治局第三十六次集体学习",
          source: "红网",
          emotion: "积极",
          industry: "政府部门",
          cause: "党建活动",
          article: "时事",
          time: "26分钟前"
        },{
          title: "宝能汽车集团副总裁陆惟一：技术就是竞争力",
          source: "投资者网",
          emotion: "积极",
          industry: "汽车行业",
          cause: "行业竞争",
          article: "汽车",
          time: "30分钟前"
        },{
          title: "上海凤凰最新公告：2021年度净利同比预增69.62%左右",
          source: "证券之星",
          emotion: "中性",
          industry: "政府部门",
          cause: "党建活动",
          article: "房产",
          time: "30分钟前"
        },{
          title: "2021年，全球销量最高的车是谁？",
          source: "科技每日推送",
          emotion: "中性",
          industry: "汽车行业",
          cause: "榜上有名",
          article: "汽车",
          time: "30分钟前"
        }
      ],
      totalRows: 100,
      currentPage: 1,
      perPage: 10,
      fields: [
        { key: "title", label: "标题" },
        { key: "source", label: "来源" },
        { key: "emotion", label: "情感标签" },
        { key: "cause", label: "事件标签" },
        { key: "article", label: "文章分类" },
        { key: "industry", label: "行业标签" },
        { key: "time", label: "时间" }
      ],
      showModal: false,
      showModalGrouping: false,
      groupingName: "",
      classificationName: "",
      labelType: "",
      labelTypeList: ['类型一','类型二'],
    };
  },
  watch: {
    "currentPage": {
      handler(){
        console.log("触发分页");
      }
    }
  },
  methods: {
    /**
     * Search the table data with search input
     */
    onFiltered(filteredItems) {
      // Trigger pagination to update the number of buttons/pages due to filtering
      this.totalRows = filteredItems.length;
      this.currentPage = 1;
    },
    // 种子详情
    seedDetail(row){
      console.log(row);
      this.$router.push('/spider/siteDetail')
    },
    handleClose(){
      this.showModal = false
      this.showModalGrouping = false
    },
    addLabel(){
      this.$router.push('/lable/addLabel')
    }
  }
};
</script>

<template>
  <div>
    <!-- 搜索 -->
    <div class="search-box">
      <div class="position-relative search">
        <input type="text" class="form-control" placeholder="请输入标记数据" />
        <i class="mdi mdi-magnify search-icon"></i>
      </div>
    </div>
    <div class="allNum">
      <div class="searchNum">为您检索到<span>5,000+</span>条标记数据</div>
      <div>
        <b-dropdown dropup variant="secondary" class="butn">
          <template slot="button-content">
            <i class="ri-add-line align-middle" style="font-size: 1rem;"></i>
            <span style="margin:0 20px 0 6px;">标签管理</span>
            <i class="mdi mdi-chevron-up"></i>
          </template>
          <b-dropdown-item-button @click="addLabel">创建标签</b-dropdown-item-button>
          <b-dropdown-item-button @click="showModalGrouping=true">创建分组</b-dropdown-item-button>
          <b-dropdown-item-button @click="showModal=true">创建分类</b-dropdown-item-button>
        </b-dropdown>
      </div>
    </div>
    <div class="table-responsive">
      <b-table
        class="table-centered"
        :items="ordersData"
        :fields="fields"
        responsive="sm"
        :per-page="perPage"
        :current-page="1"
        thead-class="thead-light"
        @filtered="onFiltered"
      >
        <template v-slot:cell(title)="row">
          <a style="font-size:.9rem;" href="/#/lable/signDetail">{{row.value}}</a>
        </template>
        <template v-slot:cell(emotion)="row">
          <div v-if="row.value=='积极'" class="badge font-size-12 badge-soft-success">{{ row.value}}</div>
          <div v-if="row.value=='中性'" class="badge font-size-12 badge-soft-warning">{{ row.value}}</div>
          <div v-if="row.value=='消极'" class="badge font-size-12 badge-soft-danger">{{ row.value}}</div>
        </template>
        <template v-slot:cell(industry)="row">
          <div class="badge font-size-12 badge-soft-primary">{{ row.value}}</div>
        </template>
      </b-table>
    </div>
    <div class="row">
      <div class="col">
        <div class="dataTables_paginate paging_simple_numbers float-right">
          <ul class="pagination pagination-rounded mb-0">
            <!-- pagination -->
            <b-pagination v-model="currentPage" :total-rows="totalRows" :per-page="perPage"></b-pagination>
          </ul>
        </div>
      </div>
    </div>
    <el-dialog
      title="添加分类"
      :visible.sync="showModal"
      width="40%"
      :before-close="handleClose">
      <form>
        <div class="form-group">
          <label for="productname">分类名称</label>
          <b-form-input
            for="text"
            v-model="classificationName"
            placeholder="请输入一个分类名称，不能大于6个字，不能有特殊符号"
          ></b-form-input>
        </div>
      </form>
      <span slot="footer" class="dialog-footer">
        <b-button variant="primary" @click="showModal = false">
          提交
        </b-button>
      </span>
    </el-dialog>
    <el-dialog
      title="添加分组"
      :visible.sync="showModalGrouping"
      width="40%"
      :before-close="handleClose">
      <form>
        <div class="form-group">
          <label for="productname">标签类型</label>
          <multiselect
            v-model="labelType"
            :options="labelTypeList"
            placeholder="请选择一个标签数据分类项"
          ></multiselect>
        </div>
        <div class="form-group">
          <label for="productname">分组名称</label>
          <b-form-input
            for="text"
            v-model="groupingName"
            placeholder="请输入一个分组名称，不能大于6个字，不能有特殊符号"
          ></b-form-input>
        </div>
      </form>
      <span slot="footer" class="dialog-footer">
        <b-button variant="primary" @click="showModalGrouping = false">
          提交
        </b-button>
      </span>
    </el-dialog>
  </div>
</template>
<style lang="scss" scoped>
.search {
  max-width: 300px;
  margin-bottom: 20px;
}
.border-radius{
  border-radius: 0px;
  border-bottom-left-radius: 30px;
  border-top-left-radius: 30px;
}
.right-dropdown{
  ::v-deep .btn{
    font-size: 0;
    border-radius: 0px;
    padding: 0.47rem 0.5rem;
    border-bottom-right-radius: 30px;
    border-top-right-radius: 30px;
    i{
      font-size: 0.9rem;
      vertical-align: middle;
    }
  }
}
.table-centered{
  ::v-deep thead,::v-deep tbody{
    tr{
      th:last-child,td:last-child{
        text-align: right;
      }
    }
  }
  ::v-deep tbody{
    tr{
      td{
        font-size: 13px;
      }
    }
  }
}
.allNum{
  padding-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.searchNum{
  span{
    font-size: 1rem;
    color: #3444c1;
    margin: 0 4px;
    font-weight: 600;
  }
}
.butn{
  ::v-deep .btn{
    background-color: #252b3b;
    border-color: #252b3b;
    border-radius: 30px;
    display: flex;
    align-items: center;
  }
  ::v-deep .btn-secondary.focus {
    box-shadow: 0 0 0 0.15rem rgb(37 40 58 / 50%);
  }
}
::v-deep .el-dialog__footer{
  text-align: center;
}
</style>

